﻿
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace StockClientUI
{
    public partial class MdiMain : Form
    {
        public MdiMain()
        {
            InitializeComponent();
            this.skinEngine1.SkinFile = Application.StartupPath + @"\DiamondGreen.ssk";
          
        }
        public static MdiMain MAIN;
        MainF mainf;
        public static DataSet getds = new DataSet();
        /// <summary>
        /// 创建窗体
        /// </summary>
        /// <returns></returns>
        public static MdiMain Creat(DataSet ds)
        {
            if (MAIN == null || MAIN.IsDisposed)
            {
                MAIN = new MdiMain();
                getds = ds;
            }
            return MAIN;
        }

        private void MdiMain_Load(object sender, EventArgs e)
        {
            this.barManager1.GetController().PaintStyleName = "WindowsXP";//配置菜单样式
            mainf = new MainF(getds);
            mainf.MdiParent = this;
            mainf.Show();
        }

        private void MdiMain_FormClosing(object sender, FormClosingEventArgs e)
        {            
            Application.Exit();
        }

        /// <summary>
        /// 打开窗体
        /// </summary>
        /// <param name="p_Frm"></param>
        private void NavItemClick(Form p_Frm)
        {
            foreach (Form frm in this.MdiChildren)
            {
                if (frm.Name == p_Frm.Name)
                {
                    frm.Activate();
                    return;
                }
            }

            OpenChildForm(p_Frm);

        }

        /// <summary>
        /// 打开MDI子窗体
        /// </summary>
        /// <param name="p_Frm">MDI子窗体</param>
        private void OpenChildForm(Form p_Frm)
        {
            p_Frm.MdiParent = this;

            p_Frm.Show();
        }

        private void 更新密码ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            UpdatePassword up = new UpdatePassword();

            NavItemClick(up);
        }

        private void 退出程序ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void 用户组ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            UserGroup ugp = new UserGroup();
            NavItemClick(ugp);
            
        }

        private void 测试信息ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            UserGroup ug = new UserGroup();
            NavItemClick(ug);
        }

     
    }
}